package com.rybbaby.tss.core.hqlsearch.parse.impl;

import com.rybbaby.tss.core.hqlsearch.HqlGenerateUtil;
import com.rybbaby.tss.core.hqlsearch.parse.IHqlParse;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

/**
 * @description 长整形类型条件解析
 *
 * @author 谢进伟
 *
 * @createDate 2015-11-11 上午9:54:52
 */
public class LongParseImpl implements IHqlParse {
	
	public void addCriteria(DetachedCriteria cq , String name , Object value) {
		if(HqlGenerateUtil.isNotEmpty(value))
			cq.add(Restrictions.eq(name , value));
	}
	
	public void addCriteria(DetachedCriteria cq , String name , Object value , String beginValue , String endValue) {
		if(HqlGenerateUtil.isNotEmpty(beginValue)) {
			cq.add(Restrictions.ge(name , Long.parseLong(beginValue)));
		}
		if(HqlGenerateUtil.isNotEmpty(endValue)) {
			cq.add(Restrictions.le(name , Long.parseLong(endValue)));
		}
		if(HqlGenerateUtil.isNotEmpty(value)) {
			cq.add(Restrictions.eq(name , value));
		}
	}
	
}
